<!DOCTYPE html>
<html>
  <head>
    <script src="../dist/jspsych.js"></script>
    <script src="../dist/plugin-image-keyboard-response.js"></script>
    <script src="../dist/plugin-preload.js"></script>
    <link rel="stylesheet" href="../dist/jspsych.css">
  </head>
  <body></body>
  <script>

    var jsPsych = initJsPsych({
      default_iti: 250,
      on_finish: function() {
        jsPsych.data.displayData();
      }
    });

    var preload = {
      type: jsPsychPreload,
      auto_preload: true
    };

    var trial_1 = {
      stimulus: 'img/happy_face_4.jpg',
    };

    var trial_2 = {
      stimulus: 'img/sad_face_4.jpg',
    };

    var trial_3 = {
      stimulus: 'img/sad_face_3.jpg',
    };

    var node = {
      type: jsPsychImageKeyboardResponse,
      timeline: [trial_1, trial_2, trial_3],
      choices: ['y','n'], 
      prompt: '<p>Have you seen this face before? Press "y" or "n".</p>'+
      '<p>(After each trial, all of the data from this timeline will be printed to the console.)</p>',
      stimulus_width: 300,
      data: {
        node_data: true
      },
      on_finish: function(){
        console.log(jsPsych.data.getLastTimelineData().json());
      }
    };

    jsPsych.run([preload, node]);

  </script>
</html>
